import logging

from flask import request, make_response

from . import passport_blue
#from info.utils.captcha.captcha import captcha
from ... import redis_store
from ...utils.captcha.captcha import captcha


@passport_blue.route('/image_code')
def image_code():
    print(request.args)
    cur_id=request.args.get("cur_id")
    pre_id=request.args.get("pre_ id")
    try :
        if pre_id:
            redis_store.delete("pictureid:%s"%pre_id)
        name,text,image_data = captcha.generate_captcha()
        redis_store.set("pictureid:%s"%cur_id,image_data)
    except Exception as e:
        logging.warn(e)
        return  "redis失败"
    image_data = make_response(image_data)
    image_data
    return   image_data
